package cn.edu.lingnan.association.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.association.dao.MemberDAO;
import cn.edu.lingnan.association.dao.joinclubDAO;
import cn.edu.lingnan.association.dto.Member;


public class joinclub1Servlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException {
		
		 String mid = req.getParameter("mid");
		 
		 String mname = req.getParameter("mname");
		 byte mname2[] = mname.getBytes("ISO-8859-1");
		 mname = new String(mname2,"GBK");
		 
		 String mgender = req.getParameter("mgender");	
		 byte mgender2[] = mgender.getBytes("ISO-8859-1");
		 mgender = new String(mgender2,"GBK");
		 
		 String cname = req.getParameter("cname");
		 byte cname3[] = cname.getBytes("ISO-8859-1");
		 cname = new String(cname3,"GBK");
		 
//		 String prof = req.getParameter("prof");
//		 byte prof2[] = prof.getBytes("ISO-8859-1");
//		 prof = new String(prof2,"GBK");
//		 
		 
		 Member m = new Member();
		 joinclubDAO jd = new joinclubDAO();	 
		 m.setmId(mid);
		 m.setmName(mname);
		 m.setmGender(mgender);		 
		 m.setcName(cname);
//		 m.setProf(prof);
		 
		 int flag = jd.insertmember(m);	
		 if(flag == 1)
			 resp.sendRedirect(req.getContextPath()+"/cheak.jsp");
		 else
			 resp.sendRedirect(req.getContextPath()+"/error-404.html");
		
		 
	}

	

}
